package summer.tree;

public class Solution404 {
    public int sumOfLeftLeaves(TreeNode root) {
        return getSum(root, 1);
    }

    public int getSum(TreeNode root, int flag) {
        if (root == null) return 0;
        if (root.left == null && root.right == null && flag == -1) {
            return root.val;
        }
        return getSum(root.left, -1) + getSum(root.right, 1);
    }
}
